﻿using Elasticsearch.Net;

namespace EsApp02
{
    public static class EsExtension
    {
        public static async Task RegisterElasticSearchAsync(this IServiceCollection services)
        {
            var connStr = App.Configuration["ElasticSearch:Connection"];
            var prefix = App.Configuration["ElasticSearch:Prefix"];
            if (!string.IsNullOrEmpty(prefix)) prefix = "_" + prefix;
             var node = new Uri(connStr);
            var config = new ConnectionConfiguration(node);
            var client = new ElasticLowLevelClient(config);
            //client.
            services.AddSingleton(client);
        }
    }
}
